var __extends = this.__extends || function (d, b) {
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var SprintDef = (function (_super) {
    __extends(SprintDef, _super);
    function SprintDef() {
        _super.apply(this, arguments);

    }
    SprintDef.prototype.Ready = function () {
        $('.CheckButton').click(function () {
            var id = $(this).attr('data-id');
            Base.Page.Self.OpenSetIteration(id);
        });
        $('.EditButton').click(function () {
            var id = $(this).attr('data-id');
            Base.Page.Self.OpenUpdSprint(id);
        });
        $('.DeleteButton').click(function () {
            var id = $(this).attr('data-id');
        });
    };
    SprintDef.prototype.EditDialogComplete = function () {
        $('#dialog-sprint').dialog('close');
        window.location.reload();
    };
    SprintDef.prototype.OpenUpdSprint = function (id) {
        loadAjaxHtml("dialog-sprint", this.aUrl[0] + "/" + id, 'none', function () {
            $("#StartDate,#EndDate").datepicker({
                showOn: "button",
                buttonText: "Set"
            }).datepicker($.datepicker.regional[g_cultureJS]);
            $('#dialog-sprint').dialog({
                autoOpen: false,
                width: 500,
                modal: true,
                hide: "highlight",
                buttons: {
                    Cancel: function () {
                        $(this).dialog("close");
                    },
                    "Save": function () {
                        $("#SprintForm").submit();
                    }
                }
            }).dialog('open');
        });
    };
    SprintDef.prototype.OpenSetIteration = function (id) {
        loadAjaxHtml("dialog-sprint", this.aUrl[1] + "/" + id, 'none', function () {
            $('#mySelectBox').toChecklist({
                submitDataAsArray: false
            });
            $('#dialog-sprint').dialog({
                autoOpen: false,
                width: 400,
                height: 550,
                modal: true,
                hide: "highlight",
                buttons: {
                    Cancel: function () {
                        $(this).dialog("close");
                    },
                    "Save": function () {
                        var selectedValues = new Array();
                        $("#mySelectBox input:checked").each(function () {
                            selectedValues.push($(this).val());
                        });
                        if(selectedValues.length > 0) {
                            CallService("POST", Base.Page.Self.aUrl[2], {
                                sprintId: id,
                                selectedValues: selectedValues
                            }, true, function () {
                                Base.Page.Self.EditDialogComplete();
                            });
                        }
                    }
                }
            }).dialog('open');
        });
    };
    return SprintDef;
})(Base.Page);
